package o;

import android.os.AsyncTask;
import android.text.TextUtils;
import com.huawei.appgallery.common.media.api.OriginalMediaBean;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class bag extends AsyncTask {
    private c ˊ = null;
    private String ˋ = null;
    private bae ˎ;
    private List<OriginalMediaBean> ˏ;

    public interface c {
        void ˊ(List<String> list);
    }

    public bag(List<OriginalMediaBean> list, c cVar) {
        this.ˏ = list;
        this.ˊ = cVar;
    }

    protected Object doInBackground(Object[] objArr) {
        String str = epp.ॱ(ContentManager.getInstant().getContext()) + "forum/";
        if (TextUtils.isEmpty(str)) {
            azh.ˏ.ˊ("TranslateImgTask", "zipSelectedImages failed, uploadPath isEmpty, requestId = ");
            return null;
        }
        ˎ(str);
        this.ˋ = str + (UUID.randomUUID().toString() + "_" + System.currentTimeMillis());
        File file = new File(this.ˋ);
        if (file.exists() || file.mkdirs()) {
            this.ˎ = new bae(this.ˏ, this.ˋ, true);
            return Boolean.valueOf(this.ˎ.ˏ());
        }
        azh.ˏ.ˏ("TranslateImgTask", "create upload dir failed.");
        return null;
    }

    protected void onPostExecute(Object obj) {
        List list = null;
        if (obj == null || !((Boolean) obj).booleanValue()) {
            Logger.ˎ("TranslateImgTask", "compress jpg failed");
        } else {
            Logger.ˎ("TranslateImgTask", "compress pic success");
            if (this.ˎ != null) {
                list = this.ˎ.ˊ();
            }
        }
        if (list == null) {
            list = new ArrayList();
        }
        if (this.ˊ != null) {
            this.ˊ.ˊ(list);
        }
    }

    private void ˎ(String str) {
        File file = new File(str);
        if (file.exists()) {
            File[] listFiles = file.listFiles();
            if (listFiles != null && listFiles.length > 0) {
                for (File ˊ : listFiles) {
                    dnw.ˊ(ˊ);
                }
            }
        }
    }
}
